package com.client.biz.product;

import com.bean.Message;
import com.bean.Product;
import com.client.biz.ProductBiz;
import com.client.net.INet;
import com.client.net.NetImpl;

public class ProductBizImpl implements ProductBiz {

	@Override
	public Message updataQuantity(String url, Product p) {
		return request(url, p);
	}

	@Override
	public Message newProduct(Product p) {
		return request("/product/newProduct.do", p);
	}

	@Override
	public Message findAll() {
		return request("/product/findAllProduct.do", null);
	}

	@Override
	public Message findById(Product p) {
		return request("/product/findByIdProduct.do", p);
	}
	
	private Message request(String url, Product p) {
		INet<Message> net = new NetImpl();
		Message message = new Message(url);
		if(p != null) {
			message.setProduct(p);
		}
		return net.execute(message);
	}

}
